Skip to content

Conversation

@mpritchard2
Copy link
Contributor

🛠️ Description

This fixes an issue in the validation of the provided time in Reset-AutomationSchedules.ps1. The current implementation was checking UTC - 1 hour against the local time of the parsed time string instead of UTC. The current implementation was also checking if sooner than an hour ago instead of sooner than an hour in the future.

Output of the original script from when I encountered the bug:

Please, enter a new base time for the weekly schedules in UTC (YYYY-MM-dd HH:mm:ss). If you want to keep the current one, just press ENTER: 2025-10-02 06:00:00
Exception: C:\Working\finops-toolkit\src\optimization-engine\Reset-AutomationSchedules.ps1:90
Line |
90 | throw "$newBaseTimeStr is an invalid base time. It can't be s …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| 2025-10-02 06:00:00Z is an invalid base time. It can't be sooner than 2025-10-02 02:56:01Z

📋 Checklist

🔬 How did you test this change?

  • 🤏 Lint tests
  • 🤞 PS -WhatIf / az validate
  • 👍 Manually deployed + verified
  • 💪 Unit tests
  • 🙌 Integration tests

🙋‍♀️ Do any of the following that apply?

  • 🚨 This is a breaking change.
  • 🤏 The change is less than 20 lines of code.

📑 Did you update docs/changelog.md?

  • ✅ Updated changelog (required for dev PRs)
  • ➡️ Will add log in a future PR (feature branch PRs only)
  • ❎ Log not needed (small/internal change)

📖 Did you update documentation?

  • ✅ Public docs in docs (required for dev)
  • ✅ Internal dev docs in src (required for dev)
  • ➡️ Will add docs in a future PR (feature branch PRs only)
  • ❎ Docs not needed (small/internal change)

@microsoft-github-policy-service microsoft-github-policy-service bot added Micro PR 🔬 Very small PR that should be especially easy for newcomers Needs: Review 👀 PR that is ready to be reviewed labels Oct 2, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Tool: Optimization Engine Azure Optimization Engine label Oct 2, 2025
@helderpinto
Copy link
Member

Thank you for the contribution, @mpritchard2. Allow me some time to review and test the proposed change.

@MSBrett MSBrett requested a review from Copilot October 10, 2025 20:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Fixes a validation bug in Reset-AutomationSchedules.ps1 where the time validation logic was incorrectly checking if the provided time was in the past instead of ensuring it's at least one hour in the future.

Key changes:

  • Corrected time comparison logic to validate future times instead of past times
  • Fixed timezone handling by using DateTimeOffset instead of DateTime for consistent UTC comparisons
  • Improved error message clarity to specify the requirement for future times

@MSBrett MSBrett requested a review from Copilot October 10, 2025 21:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

@mpritchard2
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Netchex"

Copy link
Contributor

@MSBrett MSBrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved - Bug fix correctly validates time is ≥1hr in future and uses DateTimeOffset for UTC comparison. Will add changelog post-merge since external fork.

@MSBrett MSBrett merged commit eb6087b into microsoft:dev Oct 11, 2025
1 check passed
@microsoft-github-policy-service

@all-contributors please add @mpritchard2 for code

@allcontributors
Copy link
Contributor

@microsoft-github-policy-service[bot]

I've updated the pull request to add @mpritchard2! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Micro PR 🔬 Very small PR that should be especially easy for newcomers Needs: Review 👀 PR that is ready to be reviewed Tool: Optimization Engine Azure Optimization Engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants